package com.moli.iov.protocol.enums;

/**
 * @author fudh
 * @ClassNmme TopicEnums
 * @date 2019/4/1 15:27
 */
public enum TopicEnums {
    /**
     * 车辆注册
     */
    UP_REGISTER((byte) 0xDB, "IovVehicleRegister"),

    /**
     * 车辆登陆
     */
    UP_LOGIN((byte) 0x01, "IovVehicleLogin"),

    /**
     * 实时
     */
    UP_REALTIME((byte) 0x02, "IovVehicleRealtime"),

    /**
     * 补发
     */
    UP_REISSUE((byte) 0x03, "IovVehicleReissue"),

    /**
     * 登出
     */
    UP_Logout((byte) 0x04, "IovVehicleLogout"),

    /**
     * 心跳
     */
    UP_HeartBeat((byte) 0x07, "IovVehicleHeartBeat"),

    /**
     * 终端校时
     */
    UP_TERMINALTIMING((byte) 0x08, "IovVehicleTerminalTiming"),


    DOWN_RESPONSE_D1((byte) 0xD1, "IovDownResponse"),
    DOWN_RESPONSE_D2((byte) 0xD2, "IovDownResponse"),
    DOWN_RESPONSE_D3((byte) 0xD3, "IovDownResponse"),
    DOWN_RESPONSE_D4((byte) 0xD4, "IovDownResponse"),
    DOWN_RESPONSE_D8((byte) 0xD8, "IovDownResponse"),
    DOWN_RESPONSE_D9((byte) 0xD9, "IovDownResponse"),
    DOWN_RESPONSE_DD((byte) 0xDD, "IovDownResponse");

    private byte flag;

    private String topic;

    TopicEnums(byte flag, String topic) {
        this.flag = flag;
        this.topic = topic;
    }

    public byte getFlag() {
        return flag;
    }

    public void setFlag(byte flag) {
        this.flag = flag;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }


    public static String getTopic(byte value) {

        for (TopicEnums val : TopicEnums.values()) {
            if (val.flag == value) {
                return val.topic;
            }
        }

        return "";
    }


}
